package edu.hawaii.ics414;

import java.util.ArrayList;
import java.util.HashMap;
import android.os.Parcel;
import android.os.Parcelable;

public class CalendarList implements Parcelable {
  private ArrayList<HashMap<String, String>> a;
  private String date;

  public CalendarList() {
    a = new ArrayList<HashMap<String, String>>();
    date = "";
  }
  
  public CalendarList(Parcel source) {
   a = source.readArrayList(null);
   date = source.readString();
  }

  public int describeContents() {
    return 0;
  }

  public void writeToParcel(Parcel dest, int arg1) {
    dest.writeList(a);
    dest.writeString(date);
  }

  public boolean put(HashMap<String, String> map) {
    if (a.add(map)) {
      return true;
    }
    else {
      return false;
    }
  }

  public int length() {
    return a.size();
  }

  public HashMap<String, String> getEvent(int index) {
    return a.get(index);
  }
  
  public void setDate(String date) {
    this.date = date;
  }
  
  public String getDate() {
    return date;
  }

  public String[] getTitles() {
    String[] array = new String[a.size()];
    for (int i = 0; i < a.size(); i++) {
      array[i] = a.get(i).get("title");
    }
    return array;
  }
  
 public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
    
    public CalendarList createFromParcel(Parcel source) {
      return new CalendarList(source);
    }

    public CalendarList[] newArray(int size) {
      return null;
    }

  };
}
